import { Injectable } from '@angular/core';
/**
 * 将数组转为 key-value 对象
 */
const arrayToMapping = (arr: Array<{ name: string, value: string }>): { [key: string]: string } => {
    return arr.reduce((accumulator: any, item) => {
        accumulator[item.value] = item.name;
        return accumulator;
    }, {});
};

@Injectable({
    providedIn: 'root'
})
export class ConstantService {

    constructor() { }
    /**
     * 数据源启动状态
     */
    dataSourceType = [
        { name: '普通性能', value: '0' },
        { name: '高性能', value: '1' }
    ];

    /**
     * 数据源类型 key-value 映射
     */
    dsTypeMapping = arrayToMapping(this.dataSourceType);
}
